/* DevTools Panel Styles */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  color: #333;
  background: #f5f5f5;
  overflow: hidden;
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-title h1 {
  font-size: 16px;
  font-weight: 600;
  color: #673ab7;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.divider {
	width: 100%;
	height: 2px;
	background: #e0e0e0;
	margin: 8px 0;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f44336;
  transition: background-color 0.2s;
}

.status-indicator.connected {
  background: #4caf50;
}

.status-indicator.connecting {
  background: #ff9800;
  animation: pulse 2s infinite;
}

.status-indicator.warning {
  background: #ff9800;
}

.status-indicator.disconnected {
  background: #f44336;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.header-controls {
  display: flex;
  gap: 8px;
}

/* Buttons */
.btn {
  border: 1px solid #ccc;
  background: #fff;
  color: #333;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  background: #f0f0f0;
}

.btn.btn-primary {
  background: #2196f3;
  border-color: #2196f3;
  color: white;
}

.btn.btn-primary:hover {
  background: #1976d2;
}

.btn.btn-secondary {
  background: #f5f5f5;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Settings Panel */
.settings-panel {
  position: absolute;
  top: 49px;
  left: 0;
  right: 0;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
}

.settings-content {
  padding: 16px;
}

.settings-content h3 {
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 600;
}

.setting-group {
  margin-bottom: 12px;
}

.setting-group label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
}

.setting-group input[type="checkbox"] {
  margin-right: 8px;
}

.setting-group input[type="number"],
.setting-group textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 12px;
}

.setting-group textarea {
  height: 60px;
  resize: vertical;
  font-family: monospace;
}

.settings-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Tabs */
.tabs {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  flex-shrink: 0;
}

.tab {
  padding: 12px 16px;
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: #666;
  transition: all 0.2s;
}

.tab:hover {
  color: #333;
  background: #f8f9fa;
}

.tab.active {
  color: #673ab7;
  border-bottom-color: #673ab7;
  background: #fff;
}

/* Main Content */
.main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.tab-content {
  flex: 1;
  overflow: hidden;
}

/* Empty State */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
}

.empty-state-content h2 {
  font-size: 18px;
  margin-bottom: 8px;
  color: #666;
}

.empty-state-content p {
  color: #999;
  margin-bottom: 16px;
}

/* Updates Container */
.updates-container {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.updates-header {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 8px 12px;
  flex-shrink: 0;
}

.updates-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: #666;
}

.updates-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* Update Items */
.update-item {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  margin-bottom: 8px;
  padding: 8px;
  font-size: 12px;
}

.update-item.effect {
  border-left: 4px solid #ff9800;
}

.component-name-header {
	margin-right: 8px;
}

.component-list {
	list-style: none;
	display: flex;
	padding: 0;
	margin: 0;
	font-family: monospace;
  background: #f8f9fa;
  padding: 4px 6px;
  border-radius: 3px;
}

.update-item.rerender {
  border-left: 4px solid #9c27b0;
  background-color: #fafafa;
}

.update-item.value {
  border-left: 4px solid #2196f3;
}

.update-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.update-count {
  display: inline-block;
  padding: 0 6px;
  background: #e0e0e0;
  border-radius: 12px;
  margin: 0 2px;
}

.signal-name {
  font-weight: 600;
  color: #673ab7;
}

.component-name {
  font-weight: 400;
  color: #4169E1;
  font-style: italic;
}

.update-time {
  color: #999;
  font-size: 11px;
}

.update-depth {
  color: #666;
  font-size: 11px;
}

.value-change {
  margin: 4px 0;
  font-family: monospace;
  background: #f8f9fa;
  padding: 4px 6px;
  border-radius: 3px;
}

.value-prev,
.value-new {
  display: inline-block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
}

.value-prev {
  color: #d32f2f;
}

.value-new {
  color: #388e3c;
}

.value-arrow {
  margin: 0 8px;
  color: #666;
}

/* Scrollbar styling */
.updates-list::-webkit-scrollbar {
  width: 8px;
}

.updates-list::-webkit-scrollbar-track {
  background: #f5f5f5;
}

.updates-list::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.updates-list::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* Graph Visualization */
.graph-container {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.graph-content {
  flex: 1;
  position: relative;
  background: #fafafa;
  overflow: hidden;
  user-select: none;
}

.graph-svg {
  width: 100%;
  height: 100%;
  min-height: 500px;
}

.graph-controls {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.graph-reset-button,
.graph-export-button {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: all 0.2s;
}

.graph-reset-button:hover,
.graph-export-button:hover {
  background: #f5f5f5;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.graph-reset-button:active,
.graph-export-button:active {
  background: #eeeeee;
  transform: translateY(1px);
}

.graph-export-container {
  position: relative;
}

.graph-export-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  overflow: hidden;
  min-width: 180px;
}

.graph-export-menu-item {
  display: block;
  width: 100%;
  background: white;
  border: none;
  padding: 10px 12px;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.graph-export-menu-item:hover {
  background: #f5f5f5;
}

.graph-export-menu-item:active {
  background: #eeeeee;
}

.graph-export-menu-item:not(:last-child) {
  border-bottom: 1px solid #e0e0e0;
}

.graph-node {
  cursor: pointer;
  transition: all 0.2s;
  stroke: #fff;
  stroke-width: 2;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.graph-node:hover {
  filter: brightness(1.1) drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.graph-node.signal {
  fill: #2196f3;
}

.graph-node.computed {
  fill: #ff9800;
}

.graph-node.effect {
  fill: #4caf50;
}

.graph-node.component {
  fill: #9c27b0;
}

.graph-link {
  stroke: #666;
  stroke-width: 2;
  fill: none;
  marker-end: url(#arrowhead);
}

.graph-link.highlighted {
  stroke: #673ab7;
  stroke-width: 3;
}

.graph-text {
  fill: white;
  text-anchor: middle;
  dominant-baseline: middle;
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.graph-legend {
  position: absolute;
  top: 16px;
  right: 16px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 12px;
  font-size: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.component-boundary {
  transition: all 0.2s ease;
}

.component-boundary:hover {
  fill: rgba(100, 149, 237, 0.15);
  stroke: rgba(100, 149, 237, 0.5);
}

.component-label {
  user-select: none;
  pointer-events: none;
}

.graph-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: #666;
}

.graph-toast {
  position: absolute;
  top: 16px;
  right: 16px;
  background: #323232;
  color: white;
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 1000;
  animation: slideInFade 0.3s ease-out;
}

@keyframes slideInFade {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Tree Node Styles */
.tree-node {
  margin-bottom: 4px;
}

.tree-node-content {
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

.collapse-button {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 12px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-top: 8px;
  flex-shrink: 0;
  transition: color 0.2s;
}

.collapse-button:hover {
  color: #333;
  background: #f0f0f0;
  border-radius: 2px;
}

.collapse-spacer {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 8px;
}

.update-content {
  flex: 1;
  min-width: 0;
}

.tree-children {
  margin-left: 20px;
  border-left: 1px solid #e0e0e0;
  padding-left: 4px;
  margin-top: 4px;
}

.tree-children .tree-node:last-child {
  margin-bottom: 0;
}

/* Update existing update-item styles to work better with tree */
.tree-node .update-item {
  margin-bottom: 0;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .header {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }

  .header-title {
    justify-content: center;
  }

  .header-controls {
    justify-content: center;
  }

  .graph-legend {
    position: static;
    margin: 16px;
  }

  .tree-children {
    margin-left: 12px;
  }
}
